import { $delete, $get, $post } from '@js/authRequest'
import { message } from 'antd'

export async function getListRequest (condition, pageSize, current) {
  const res = await $get('/api/tiaojie/case', {
    condition: JSON.stringify(condition),
    limit: pageSize,
    page: current
  })
  if (res.status !== 1) {
    message.error(res.message)
    throw new Error(res.message)
  }
  return res.data
}

export async function delRequest (id) {
  const res = await $delete(`/api/tiaojie/case/${id}`)
  if (res.status !== 1) {
    message.error(res.message)
    throw new Error(res.message)
  }
  return res.data
}

export async function generateFile (bizid) {
  const res = await $post('/api/vendor/file/createByKeys', {
    bizid,
    filecodes: 'shenpibiao_tiaojieanjian'
  })
  if (res.status !== 1) {
    message.error(res.message)
    throw new Error(res.message)
  }
  return res.data
}
